package xyz.fuqufyb.aec.data;

import org.apache.http.HttpStatus;

import java.util.HashMap;

/**
 * @author 用户: fyb
 * @description class: TableResult
 * @date 时间: 2021/2/1 22:34
 */
public class TableResult extends HashMap<String, Object> {

    public TableResult(){

        put("code",0) ;
        put("msg","success") ;
        put("count",0);
        put("data",null) ;
    }

    /**
     * c成功
     * @param msg
     * @return
     */
    public static  TableResult getTableResultSuccess(String msg){
        TableResult tableResult = new TableResult();
        tableResult.put("msg",msg) ;
        return tableResult;
    }

    /**
     * 成功
     * @param data
     * @return
     */
    public static  TableResult getTableResultSuccess(Object data){
        TableResult tableResult = new TableResult();
        tableResult.put("data",data) ;
        return tableResult;
    }

    /**
     * 成功
     * @param msg
     * @param data
     * @return
     */
    public static  TableResult getTableResultSuccess(String msg,Object data){
        TableResult tableResult = new TableResult();
        tableResult.put("msg",msg) ;
        tableResult.put("data",data) ;
        return tableResult;
    }

    /**
     * 成功
     * @param count
     * @param data
     * @return
     */
    public static  TableResult getTableResultSuccess(Long count,Object data){
        TableResult tableResult = new TableResult();
        tableResult.put("count",count);
        tableResult.put("data",data) ;
        return tableResult;
    }

    /**
     *成功
     * @param msg
     * @param count
     * @param data
     * @return
     */
    public static  TableResult getTableResultSuccess(String msg,Long count,Object data){
        TableResult tableResult = new TableResult();
        tableResult.put("msg",msg) ;
        tableResult.put("count",count);
        tableResult.put("data",data) ;
        return tableResult;
    }

    /**
     * 失败所有
     * @param code
     * @param msg
     * @param data
     * @return
     */
    public static  TableResult getTableResultError(Integer code,String msg,Object data){
        TableResult tableResult = new TableResult();
        tableResult.put("code",code);
        tableResult.put("msg",msg) ;
        tableResult.put("data",data) ;
        return tableResult;
    }

    /**
     *失败
     * @return
     */
    public static TableResult getTableResultError(){

        return  getTableResultError(HttpStatus.SC_INTERNAL_SERVER_ERROR,"服务器出现异常，请联系管理员",null);

    }

    /**
     * 失败，描述原因
     * @param msg
     * @return
     */
    public static TableResult getTableResultError(String msg){

        return  getTableResultError(HttpStatus.SC_INTERNAL_SERVER_ERROR,msg,null);

    }
    /**
     * 失败，描述原因加 状态码
     * @param msg
     * @return
     */
    public static TableResult getTableResultError(Integer code,String msg){

        return  getTableResultError(code,msg,null);

    }


    @Override
    public Object put(String key, Object value) {
        return super.put(key, value);
    }
}
